#!/bin/bash
go build raftserver.go
mkdir -p pack
# $1 = number of raftcluster $2 addr
echo $1, $2

for((i=1;i<=$1;i++));
do
  mkdir -p pack/$i
  cp raftserver pack/$i/
  mkdir -p pack/$i/conf
  tmp="{
    \"NodeName\": \"$i\",
    \"Nodes\": {
      \"$i\": {
        \"NodeName\": \"$i\",
        \"Addr\": \"$2\"
      }
    }
  }"
  echo ${tmp} > pack/$i/conf/cluster.json
done